import React, { Component } from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'

import About from './pages/About/About' // About是路由组件
import Home from './pages/Home/Home' // Home是路由组件
import Text from './pages/Text/Text' // Home是路由组件

import Header from './components/Header/Header' // Header是一般组件
import MyNavLink from './components/MyNavLink/MyNavLink'

export default class App extends Component {

    render() {
        return (
            <div>
                <div className="row">
                    <div className="col-xs-offset-2 col-xs-8">
                       <Header></Header>
                    </div>
                </div>
                <div className="row">
                    <div className="col-xs-offset-2 col-xs-2">
                        <div className="list-group">
                            {/* 原生html中，靠<a>跳转不同的页面 */}
                            {/* <a className="list-group-item">About</a>
                            <a className="list-group-item active">Home</a> */}
                           
                            {/* 在React中靠路由链接实现切换组件 */}
                            <MyNavLink to="/about">About</MyNavLink>
                            <MyNavLink to="/home">Home</MyNavLink>
                            <MyNavLink to="/text">Text</MyNavLink>
                        </div>
                    </div>
                    <div className="col-xs-6">
                        <div className="panel">
                            <div className="panel-body">
                                {/* 注册路由 */}
                                <Switch>
                                    <Route  path="/about" component={About} />
                                    <Route  path="/home" component={Home} />
                                    <Route path="/text" component={Text} />
                                    <Redirect to="/home" />
                                </Switch>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        )
    }
}
